## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.6 ✓ dplyr 1.0.8
## ✓ tidyr 1.2.0 ✓ stringr 1.4.0
## ✓ readr 2.1.2 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
Line plots with R (plotly.com)
事實上要產生互動式的圖表非常簡單。除了在一開始要載入plotly套件外,只需要把ggplot()的結果指給一個變項(如下方的NW.plot,然後用ggplotly(NW.plot)繪圖即可。多加一個config(displayModeBar = FALSE)是為了不要顯示plotly的控制列。
## Rows: 66 Columns: 37
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Category
## dbl (36): year, Before_Tax_Income, Net_Worth, Assets, Financial_Assets, Tran...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
可以在aes()設定要帶入圖的變數時,新增一個text變數,手動設定要呈現的動態呈現方塊。但要注意的是,要多加入一個group=1才能夠作用(WHY?)